function GetUrlParam(szParamName)
{	
	var strResult = "";
	var nStart = 0;
	var nEnd = 0;
	var start = 0;
	var end = 0;
	var strLoc = location.href.toLowerCase();
	szParamName = szParamName.toLowerCase();
	nStart = strLoc.indexOf(szParamName, 1);
	if (nStart == -1)
		strResult = "";
	else
	{
		//nEnd = InStr(nStart, location.href, "&");	
		nEnd = strLoc.indexOf( "&", nStart);
		if ( nEnd == -1 )
		{
			//strResult = mid(location.href, nStart + len(szParamName));
			strResult = strLoc.substring(nStart + szParamName.length )
		}
		else
		{
			if (nEnd > nStart )	
			{	
				start = nStart + szParamName.length;
				end = nEnd - nStart - szParamName.length;	
				strResult = strLoc.substring( nStart + szParamName.length, nEnd );	
			}		
		}
	}
	return strResult;
}

function isemail(str)
{
	var result=str.match(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
	if(result == null )
		return false;
	return true;
}

function isnumber(str)
{
	return !isNaN(str);
}

function isphone( str )
{
	var result = str.match(/^(13|15|16|18)[0-9]{9}$/ );
	if(result==null)
		return false;
	return true;
}

function getCookie(c_name)
{
 if (document.cookie.length > 0)
 {
  c_start = document.cookie.indexOf(c_name + "=")
  if (c_start != -1)
  {
   c_start = c_start + c_name.length + 1;
   c_end   = document.cookie.indexOf(";",c_start);
   if (c_end == -1) 
   {
    c_end = document.cookie.length;
   }
   return unescape(document.cookie.substring(c_start,c_end));
  } 
 }
 return null
}

function setCookie(c_name,value,expiredays)
{
 var exdate = new Date();
 exdate.setDate(exdate.getDate() + expiredays);
 // 使设置的有效时间正确。增加toGMTString()
 document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";path=/;expires=" + exdate.toGMTString());
}

function gup(id, dz_url) {
    id = id.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+id+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec(dz_url);
    if( results == null ) {
        return "";
    } else {
        return results[1];
    }
}

function Adjust(objName)
{
	var stxt = document.getElementById(objName).value;
	if (stxt == "" || stxt == "输入您想要的宝贝名称或网址~")
	{
		document.getElementById(objName).value = "";
		return true;
	}
	if (stxt.indexOf(".com") == -1)
		return true;

//	alert(stxt);
	var url_id = "";
	if(gup("id", stxt) != "")
		url_id = gup("id", stxt); 
	else if(gup("item_num_id", stxt) != "" )
		url_id = gup("item_num_id", stxt);
	else if(gup("item_id", stxt) != "" )
		url_id = gup("item_id", stxt);
	else if(gup("mallstItemId", stxt) != "" )
		url_id = gup("mallstItemId", stxt);
	
	if (url_id=="")
		return true;

	document.getElementById("id").value = url_id;
	document.getElementById("url").value = stxt;

	//
//	alert(url_id);
	url = "http://123.gouwutu.com/taobaoapi/get_item_info.php?itemid=" + url_id;
	$.ajax({url: url,
			async: false,
			success:function(res)
			{
				var resObj = eval('(' + res + ')');
				if (resObj.code == 1)
				{
					var div = document.createElement('div');
					div.innerHTML = resObj.title;
					stxt = div.innerText;
					stxt = stxt.replace("\"“"," ");
					stxt = stxt.replace("“"," ");
					stxt = stxt.replace("”"," ");
					document.getElementById(objName).value = stxt;
				}
			}
		});
		
	return true;
}